<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>工资管理</title>
    <#include "/common/link.ftl">

</head>
<body class="hold-transition skin-black sidebar-mini">
<div class="wrapper">
    <#include "/common/navbar.ftl">

    <#assign currentMenu="salaryReport"/>

    <#include "/common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>工资管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/salary/list" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <div class="form-group">
                        <label for="keyword">关键字:</label>
                        <input type="text" class="form-control" name="name" placeholder="请输入姓名" value="${qo.name}">
                    </div>
                    <div class="form-group">
                        <label> 发放方式:</label>
                        <select class="form-control" name="categoryId" id="categoryId">
                            <option value="">全部</option>
                            <#list type as tmp>
                                <option value="${tmp.id}">${tmp.title}</option>
                            </#list>
                        </select>
                        <script>
                            $("#categoryId").val(${qo.categoryId})
                        </script>
                    </div>
                    <div class="form-group">
                        <label>工资范围查询：</label>
                        <input placeholder="请输入最低工资" type="text" class="form-control " name="minSalary"
                               value="${qo.minSalary}"/> -
                        <input placeholder="请输入最高工资" type="text" class="form-control " name="maxSalary"
                               value="${qo.maxSalary}"/>
                    </div>
                    <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询
                    </button>
                    <a href="javascript:;" id="addBtn" class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive">
                    <table class="table table-hover table-bordered table-striped">
                        <thead>
                        <tr>
                            <th>编号</th>
<#--                            <th>年份</th>-->
                            <th>月份</th>
                            <th>姓名</th>
                            <th>基本工资</th>
                            <th>津贴</th>
                            <th>请假扣除</th>
                            <th>考勤扣除</th>
                            <th>保险扣除</th>
                            <th>应发工资</th>
                            <th>发放方式</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#list result.list as tmp>
                            <tr>
                                <td>${tmp_index+1}</td>
                                <td>${tmp.month}</td>
                                <td>${tmp.employee.name}</td>
                                <td>${tmp.money}</td>
                                <td>${tmp.subsidy}</td>
                                <td>${tmp.deduct}</td>
                                <td>${tmp.check}</td>
                                <td>${tmp.insurance}</td>
                                <td>${tmp.payroll}</td>
                                <td>${tmp.systemDictionaryItem.title}</td>
                                <td>
                                    <a href="#" class="btn btn-info btn-xs btn-input banji" data-json='${tmp.json}' >
                                        <span class="glyphicon glyphicon-pencil" ></span> 编辑
                                    </a>
                                </td>
                            </tr>
                        </#list>

                        </tbody>
                    </table>
                    <#include "/common/page.ftl" >
                </div>
            </div>
        </section>
    </div>
    <#include "/common/footer.ftl" >
</div>


<!-- Modal -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">新增/编辑</h4>
            </div>
            <form class="form-horizontal" action="/salary/saveOrUpdate" method="post" id="editForm">
                <div class="modal-body">
                    <input type="hidden" name="id" id="id">

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-3 control-label">年份：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="year" id="year"
                                   placeholder="请输入年份">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-3 control-label">月份：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="month" id="month"
                                   placeholder="请输入月份">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-3 control-label">员工：</label>
                        <div class="col-sm-6">
                            <select type="text" class="form-control" name="employee.id" id="employeeId">
                                <#list employees as tmp>
                                    <option value="${tmp.id}">${tmp.name}</option>
                                </#list>
                            </select>
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-3 control-label">工资：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="money" id="money"
                                   placeholder="请输入工资">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-3 control-label">发放方式：</label>
                        <div class="col-sm-6">
                            <select type="text" class="form-control" name="systemDictionaryItem.id" id="cateId">
                                <#list type as tmp>
                                    <option value="${tmp.id}">${tmp.title}</option>
                                </#list>
                            </select>
                        </div>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary btn-submit" id="addSubmit">保存</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    $("#addBtn").click(function () {
        $("#editModal").modal("show");
    })
    $("#addSubmit").click(function () {
        $("#editForm").submit();
    })
    $(".banji").click(function () {
        var salary = $(this).data("json");
        $("#id").val(salary.id)
        $("#year").val(salary.year)
        $("#month").val(salary.month)
        // $("#employeeId").val(salary.employee.id)
        // $("#cateId").val(salary.systemDictionaryItem.id)
        $("#money").val(salary.money)
        $("#editModal").modal("show");
    })
</script>
</body>
</html>
